package com.thoughtworks.collection;

import sun.reflect.generics.reflectiveObjects.NotImplementedException;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

public class MyMap {

    List<Integer> array;
    private String[] letters = new String[]{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l",
            "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
    private List<String> letterList = Arrays.asList(letters);

    public MyMap(List<Integer> array) {
        this.array = array;
    }

    public List<Integer> getTriple() {
        ArrayList<Integer> list = new ArrayList<>();
        Integer v = 0;
        for (Integer a :array) {
            v = a * 3 ;
            list.add(v);
        }
        return list;
    }

    public List<String> mapLetter() {
        ArrayList<String> list = new ArrayList<>();
        for (Integer a :array) {
            String s = letterList.get(a - 1);
            list.add(s);
        }
        return list;
    }

    public List<String> mapLetters() {
        ArrayList<String> list = new ArrayList<>();
        String s = "";
        for (Integer a :array) {
            if (a <= 26){
                s = letterList.get(a-1);
                list.add(s);
            }else if (a<52){
                Integer index = a %26-1;
               String k = letterList.get(index);
               s = "a" + k;
               list.add(s);
            }
            else if (a==52){
                list.add("az");
            }
            else if (52<a&&a<78){
                Integer index = a %26-1;
                String k = letterList.get(index);
                s = "b" + k;
                list.add(s);
            }
        }

        return list;
    }

    public List<Integer> sortFromBig() {

        array.sort(Comparator.reverseOrder());
        return  array;
    }

    public List<Integer> sortFromSmall() {
        array.sort(Comparator.naturalOrder());
        return  array;
    }
}
